<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/web/commons/global.jsp"%>
<c:set var="isNotShowLoginBar" value="true"></c:set>

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>极乐佛经网-提供大藏经下载大全_佛经念诵_经书抄写_助印经书_经书结缘</title>

<meta name="keywords" content="极乐佛经登录,极乐佛经,极乐佛经网,极乐佛经官网" />
<meta name="description"
	content="极乐佛经|极乐佛经网|佛经大全|佛经下载|佛经念诵|经书抄写|助印经书|经书结缘-极乐佛经网。极乐佛经网是由净顺居士发心为广大佛友所编辑整理的在线看经、在线阅读佛经平台；包含佛经原文，佛经译文，佛经注音，佛经故事，佛经视 频，大藏经等相关佛教经典大全；让更多的佛友能从中学习到佛经、佛法的善知识！" />

<link rel="shortcut icon"
	href="${baseUrl }/resources/img/favicon.ico?a=3" type="image/x-icon" />
<link rel="bookmark" href="${baseUrl }/resources/img/favicon.ico?a=3"
	type="image/x-icon" />
<link rel="stylesheet"
	href="${baseUrl }/resources/bootstrap-3.3.5/css/bootstrap.min.css" />
<link
	href="${baseUrl }/resources/font/Font-Awesome-3.2.1/css/font-awesome.min.css"
	rel="stylesheet" />
<link rel="stylesheet" href="${baseUrl }/resources/css/app.css" />
<link rel="stylesheet" href="${baseUrl }/resources/css/login.css" />

<script src="${baseUrl }/resources/js/jquery-2.1.4.min.js"
	type="text/javascript">
	
</script>
<script src="${baseUrl }/resources/bootstrap-3.3.5/js/bootstrap.min.js"
	type="text/javascript">
	
</script>

<script src="${baseUrl }/resources/js/common.js" type="text/javascript"></script>
</head>

<body>
	<%@ include file="/WEB-INF/jsp/web/commons/header.jsp"%>

	<div class="main-content-wrapper">
		<div class="main-content-wrapper-split">
			<section class="main-content">
				<div class="login-div">
					<div class="login-form-div">

						<form class="form-horizontal login-form" method="post">
							<fieldset>
								<div id="legend" class="">
									<legend class="form-legend">登录</legend>
								</div>
								<div class="form-group">
									<label for="inputAccount" class="col-sm-2 control-label">账户</label>
									<div class="col-sm-10">
										<input type="tel" class="form-control" id="inputAccount"
											name="telphone" placeholder="请输入手机号">
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword" class="col-sm-2 control-label">密码</label>
									<div class="col-sm-10">
										<input type="password" class="form-control" id="inputPassword"
											name="password" placeholder="请输入密码">
									</div>
								</div>

								<div class="form-group">
									<label for="inputValidata" class="col-sm-2 control-label">
										<!--验证码-->
									</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="inputValidata"
											name="validataImg" placeholder="验证码">
									</div>
									<div class="col-sm-6">
										<img class="validata-img" src="${baseUrl }/validata/img"
											onclick="refreshCode()" />
										<!--<i class="icon-refresh icon-spin icon-large"></i>-->
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-4">
										<div class="checkbox">
											<label> <input type="checkbox" name="remember"
												value="true"> 下次自动登录
											</label>
										</div>
									</div>
									<div class="col-sm-3 forget-password">
										<a href="">忘记密码</a>
									</div>
									<div class="col-sm-3 register">
										<a href="${baseUrl }/register/page.html">注册</a>
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<button type="button" class="btn btn-default" id="loginButton">
											<i class="icon-signin"></i>&nbsp;登录
										</button>
									</div>
								</div>
							</fieldset>
						</form>
					</div>

				</div>

			</section>

			<%@ include file="/WEB-INF/jsp/web/commons/footer.jsp"%>

		</div>
	</div>

	<script>
		var loginForm = $('.login-form');
		$(function() {
			var options = {
				msg : '',
				time : 3000,
				hasClose : true
			};

			$('#loginButton')
					.click(
							function() {
								var telphone = loginForm.find(
										"input[name='telphone']").val();
								var pssword = loginForm.find(
										"input[name='password']").val();
								var validata = loginForm.find(
										"input[name='validataImg']").val();

								if (!telphone || !$.trim(telphone)) {
									options.type = SELF_ALERT_TYPES.warning;
									options.msg = "请输入手机号";
									selfAlert(options);
									loginForm.find("input[name='telphone']")
											.closest(".form-group").addClass(
													'has-warning');

									return false;
								} else if (!telphone.match(/^\d{11}$/)) {
									options.type = SELF_ALERT_TYPES.warning;
									options.msg = "请正确输入手机号";
									selfAlert(options);
									loginForm.find("input[name='telphone']")
											.closest(".form-group").addClass(
													'has-warning');
									return false;
								}

								loginForm.find("input[name='telphone']")
										.closest(".form-group").removeClass(
												'has-warning').removeClass(
												"has-error");

								if (!pssword || !$.trim(pssword)) {
									options.type = SELF_ALERT_TYPES.warning;
									options.msg = "请输入密码";
									selfAlert(options);
									loginForm.find("input[name='password']")
											.closest(".form-group").addClass(
													'has-warning');
									return false;
								}

								loginForm.find("input[name='password']")
										.closest(".form-group").removeClass(
												'has-warning').removeClass(
												"has-error");

								if (!validata || !$.trim(validata)) {
									options.type = SELF_ALERT_TYPES.warning;
									options.msg = "请输入验证码";
									selfAlert(options);
									loginForm.find("input[name='validataImg']")
											.closest(".form-group").addClass(
													'has-warning');
									return false;
								}

								loginForm.find("input[name='validataImg']")
										.closest(".form-group").removeClass(
												'has-warning').removeClass(
												"has-error");

								var data = loginForm.serialize();
								$
										.ajax({
											async : false,
											type : "POST",
											data : data,
											url : "${baseUrl }/login",
											success : function(responseData) {
												if (responseData.responseCode == '000') {
													options.type = SELF_ALERT_TYPES.success;
													options.msg = "登录成功,正在跳转...";
													selfAlert(options);
													window.location.reload();
												} else {
													if (responseData.responseCode == "010") {
														loginForm
																.find(
																		"input[name='validataImg']")
																.closest(
																		".form-group")
																.addClass(
																		'has-error');
													} else if (responseData.responseCode == "001") {
														loginForm
																.find(
																		"input[name='telphone']")
																.closest(
																		".form-group")
																.addClass(
																		'has-error');
													} else if (responseData.responseCode == "003") {
														loginForm
																.find(
																		"input[name='password']")
																.closest(
																		".form-group")
																.addClass(
																		'has-error');
													}

													refreshCode();
													options.type = SELF_ALERT_TYPES.danger;
													options.msg = responseData.responseMessage;
													selfAlert(options);
												}
											}
										});
								return false;
							});

			//监控表单enter事件
			loginForm.find('input').bind('keydown', function(e) {
				var key = e.which;
				if (key == 13) {
					$('#loginButton').trigger('click');
				}
			});

		});

		function refreshCode() {
			loginForm.find(".validata-img").attr("src",
					"${baseUrl }/validata/img?t=" + Math.random());
		}
	</script>

</body>

<script src="${baseUrl }/resources/js/app.js" type="text/javascript">
	
</script>

</html>